package com.mcc.app.finish.controller;

import java.util.Date;
import java.util.List;
import com.mcc.common.utils.SecurityUtils;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mcc.common.annotation.Log;
import com.mcc.common.core.controller.BaseController;
import com.mcc.common.core.domain.AjaxResult;
import com.mcc.common.enums.BusinessType;
import com.mcc.app.finish.domain.FinishedQualityStandards;
import com.mcc.app.finish.service.IFinishedQualityStandardsService;
import com.mcc.common.core.page.TableDataInfo;

/**
 * 成品质量标准
 *
 * @author gxy
 * @date 2025-04-03
 */
@Api(tags = "成品质量标准")
@RestController
@RequestMapping("/quality/standards")
public class FinishedQualityStandardsController extends BaseController {

    @Autowired
    private IFinishedQualityStandardsService finishedQualityStandardsService;

    @ApiOperation("查询成品质量标准列表")
    @ApiOperationSupport(order = 1)
    @PreAuthorize("@ss.hasPermi('demo:standards:list')")
    @GetMapping("/list")
    public AjaxResult<TableDataInfo<FinishedQualityStandards>> list(FinishedQualityStandards finishedQualityStandards) {
        List<FinishedQualityStandards> list = finishedQualityStandardsService.selectFinishedQualityStandardsList(finishedQualityStandards);
        return getDataTable(list);
    }

    @ApiOperation("查询成品质量标准列表(分页)")
    @ApiOperationSupport(order = 2)
    @PreAuthorize("@ss.hasPermi('demo:standards:list')")
    @GetMapping("/page")
    public AjaxResult<TableDataInfo<FinishedQualityStandards>> page(FinishedQualityStandards finishedQualityStandards) {
        startPage();
        List<FinishedQualityStandards> list = finishedQualityStandardsService.selectFinishedQualityStandardsList(finishedQualityStandards);
        return getDataTable(list);
    }

    @ApiOperation("获取成品质量标准详细信息")
    @ApiOperationSupport(order = 3)
    @PreAuthorize("@ss.hasPermi('demo:standards:query')")
    @GetMapping("/get/{id}")
    public AjaxResult<FinishedQualityStandards> getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(finishedQualityStandardsService.selectFinishedQualityStandardsById(id));
    }

    @ApiOperation("新增成品质量标准")
    @ApiOperationSupport(order = 4)
    @PreAuthorize("@ss.hasPermi('demo:standards:add')")
    @Log(title = "成品质量标准", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody FinishedQualityStandards finishedQualityStandards) {
        return toAjax(finishedQualityStandardsService.insertFinishedQualityStandards(finishedQualityStandards));
    }

    @ApiOperation("修改成品质量标准")
    @ApiOperationSupport(order = 5)
    @PreAuthorize("@ss.hasPermi('demo:standards:edit')")
    @Log(title = "成品质量标准", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody FinishedQualityStandards finishedQualityStandards) {
        return toAjax(finishedQualityStandardsService.updateFinishedQualityStandards(finishedQualityStandards));
    }

    @ApiOperation("删除成品质量标准")
    @ApiOperationSupport(order = 6)
    @PreAuthorize("@ss.hasPermi('demo:standards:remove')")
    @Log(title = "成品质量标准", businessType = BusinessType.DELETE)
	@PostMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(finishedQualityStandardsService.deleteFinishedQualityStandardsByIds(ids));
    }
}
